package com.rogo.rogobox.controllers
{
	import com.rogo.mvc.interfaces.INotification;
	import com.rogo.mvc.sub.command.Command;
	import com.rogo.rogobox.App;
	import com.rogo.rogobox.views.components.windows.TipWindow;
	import com.rogo.util.DesktopUtil;
	
	import flash.events.Event;
	
	public class ShowTipCommand extends Command
	{
		public function ShowTipCommand()
		{
			super();
		}
		
		override public function execute(notification:INotification):void
		{
			var msg:String = notification.param.toString();
			
			if (!App.getInstance().tipWindow)
			{
				App.getInstance().tipWindow = new TipWindow();
				App.getInstance().tipWindow.addEventListener(Event.CLOSE, tipWindow_closeHandler);
				App.getInstance().tipWindow.open();
				App.getInstance().tipWindow.orderToFront();
				DesktopUtil.moveToCenter(App.getInstance().tipWindow.nativeWindow);
				App.getInstance().tipWindow.move(App.getInstance().tipWindow.nativeWindow.x, 100);
			}
			App.getInstance().tipWindow.tip(msg);
		}
		
		private function tipWindow_closeHandler(e:Event):void
		{
			App.getInstance().tipWindow = null;
		}
		
	}
}